#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        srand(time(nullptr));
        qsort(nums, 0, nums.size() - 1);
        return nums[nums.size() - k];
    }
    void qsort(vector<int>& nums, int left, int right)
    {
        if (left >= right) return;
        int r = rand() % (right - left + 1) + left;
        swap(nums[r], nums[left]);
        int keyi = left;
        int prev = left, cur = left + 1;
        while (cur <= right)
        {
            if (nums[cur] < nums[keyi] && ++prev != cur)
            {
                swap(nums[cur], nums[prev]);
            }
            cur++;
        }
        swap(nums[keyi], nums[prev]);
        qsort(nums, left, prev - 1);
        qsort(nums, prev + 1, right);

    }
};